package org.dna.opdracht1;

import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class OpdrachtTest {
	private static RandomFrame frame = null;
	
	@BeforeClass
	public static void testSetup() {
		frame = new RandomFrame();
	}
	
	@AfterClass
	public static void testCleanup() {
		frame = null;
	}
	
	@Test
	public void testHasDuplicates() {
		assertTrue(frame.hasDuplicates(new int[]{0,2,7,4,3,2,7}));
	}
	
	@Test
	public void testNotHasDuplicates() {
		assertFalse(frame.hasDuplicates(new int[]{0,1,7,4,3,2,9}));
	}
	@Test
	public void testIsSorted() {
		assertTrue(frame.isSorted(new int[]{0,1,2,3,4,5,6,7,8,9}));
	}
	
	@Test
	public void testIsSortedTwo() {
		assertTrue(frame.isSorted(new int[]{0,1,2,6,7,9}));
	}
	
	@Test
	public void testNotIsSorted() {
		assertFalse(frame.isSorted(new int[]{0,1,2,3,4,5,6,7,9,8}));
	}

	@Test
	public void testNotIsSortedTwo() {
		assertFalse(frame.isSorted(new int[]{9,10,0,3,6,7,8}));
	}
	
	@Test
	public void testArrayContains() {
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5},new int[]{0,1,2,3,4,5}));
	}

	@Test
	public void testArrayNotContains() {
		assertFalse(frame.arrayContains(new int[]{0,1,2,3,4,5},new int[]{0,1,2,4,5}));
	}
	
	@Test
	public void testArrayContainsShuffled() {
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5},new int[]{0,5,2,4,3,1}));
	}

	@Test
	public void testArrayNotContainsShuffled() {
		assertFalse(frame.arrayContains(new int[]{0,1,2,3,4,5},new int[]{5,5,5,5,5}));
	}
	
	@Test
	public void testAlgorithmOne() {
		RandomOne random = new RandomOne("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9}, array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmTwo() {
		RandomTwo random = new RandomTwo("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9},array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmThree() {
		RandomThree random = new RandomThree("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9},array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmOneNot() {
		RandomOne random = new RandomOne("algorithm name");
		int[] array = random.randomInt(10);
		assertFalse(frame.arrayContains(new int[]{1,2,3,4,5,6,7,8,9,10},array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmTwoNot() {
		RandomTwo random = new RandomTwo("algorithm name");
		int[] array = random.randomInt(10);
		assertFalse(frame.arrayContains(new int[]{1,2,3,4,5,6,7,8,9,10},array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmThreeNot() {
		RandomThree random = new RandomThree("algorithm name");
		int[] array = random.randomInt(10);
		assertFalse(frame.arrayContains(new int[]{1,2,3,4,5,6,7,8,9,10},array));
		assertFalse(frame.hasDuplicates(array));
	}
	
	@Test
	public void testAlgorithmOneIsShuffled() {
		RandomOne random = new RandomOne("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9}, array));
		assertFalse(frame.hasDuplicates(array));
		assertFalse(frame.isSorted(array));
	}
	
	@Test
	public void testAlgorithmTwoIsShuffled() {
		RandomFrame frame = new RandomFrame();
		RandomTwo random = new RandomTwo("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9},array));
		assertFalse(frame.hasDuplicates(array));
		assertFalse(frame.isSorted(array));
	}
	
	@Test
	public void testAlgorithmThreeIsShuffled() {
		RandomFrame frame = new RandomFrame();
		RandomThree random = new RandomThree("algorithm name");
		int[] array = random.randomInt(10);
		assertTrue(frame.arrayContains(new int[]{0,1,2,3,4,5,6,7,8,9},array));
		assertFalse(frame.hasDuplicates(array));
		assertFalse(frame.isSorted(array));
	}
	
}
